<%--@elvariable id="pageMap" type="java.util.Map"--%>
<%--@elvariable id="questionList" type="java.util.Map"--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <meta charset="utf-8"/>
    <title>问题帮</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
    <meta content="" name="description"/>
    <meta content="" name="author"/>
    <base href="<%=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/scorm/ "%> "/>

    <!-- BEGIN GLOBAL MANDATORY STYLES -->
    <link href="corporate/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <link href="corporate/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <!-- END GLOBAL MANDATORY STYLES -->

    <!-- BEGIN PAGE LEVEL PLUGIN STYLES -->
    <link href="corporate/plugins/fancybox/source/jquery.fancybox.css" rel="stylesheet"/>
    <link href="corporate/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
    <!-- END PAGE LEVEL PLUGIN STYLES -->

    <!-- BEGIN THEME STYLES -->
    <link href="corporate/css/style-metronic.css" rel="stylesheet" type="text/css"/>
    <link href="corporate/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="corporate/css/pages/search-page-results.css" rel="stylesheet" type="text/css"/>
    <link href="corporate/css/themes/blue.css" rel="stylesheet" type="text/css" id="style_color"/>
    <link href="corporate/css/style-responsive.css" rel="stylesheet" type="text/css"/>
    <link href="corporate/css/custom.css" rel="stylesheet" type="text/css"/>
    <!-- END THEME STYLES -->

    <link rel="stylesheet" type="text/css" href="js/common/alertMsg/alertMsg.css"/>
    <link rel="stylesheet" type="text/css" href="js/common/ccjcJS/validate.css"/>
    <link rel="stylesheet" type="text/css" href="js/common/jquery-easyui-1.3.4/themes/bootstrap/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="js/common/jquery-easyui-1.3.4/themes/icon.css"/>

    <script src="js/common/jquery-easyui-1.3.4/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="js/common/common.js" type="text/javascript"></script>

</head>
<!-- END HEAD -->

<!-- BEGIN BODY -->
<body>
<form id="search" method="post" action="">

    <!-- BEGIN PAGE CONTAINER -->
    <div class="page-container">

        <!-- BEGIN BREADCRUMBS -->
        <div class="row breadcrumbs margin-bottom-40">
            <div class="container">
                <div class="col-md-4 col-sm-4">
                    <h1>问题帮</h1>
                </div>
                <div class="col-md-8 col-sm-8">
                </div>
            </div>
        </div>
        <!-- END BREADCRUMBS -->

        <!-- BEGIN CONTAINER -->
        <div class="container min-hight">
            <div class="row margin-bottom-40">
                <div class="col-md-12 col-sm-12">
                    <!-- BEGIN SEARCH FORM ON PAGE RESULTS -->
                    <div class="row search-form-default">
                        <div class="input-group">
                            <div class="input-cont">
                                <input id="write" name="write" placeholder="请输入..." class="form-control"
                                       type="text" value=""/>
                            </div>
                                    <span class="input-group-btn">
                                        <button class="btn btn-default theme-btn" type="submit" onclick="inquiry()">查询
                                            <i class="m-icon-swapright m-icon-white"></i></button>
                                        <c:if test="${isLogin}">
                                            <button class="btn btn-default"
                                                    style="color:#fff;background: #db3a1b !important;" type="submit"
                                                    onclick="myQuestion()">
                                                我要问<i class="m-icon-swapright m-icon-white"></i>
                                            </button>
                                        </c:if>
                                    </span>
                        </div>
                    </div>
                    <!-- END SEARCH FORM ON PAGE RESULTS -->
                    <c:if test="${pageMap['endCount']>0}">
                        <!-- BEGIN SEARCH RESULTS -->
                        <c:forEach var="i" begin="${pageMap['beginCount']}"
                                   end="${pageMap['endCount']-1}">

                            <div class="search-result-item">
                                <c:if test="${isLogin}">

                                    <h4><a href="javascript:void(0);"
                                           onclick="questionInfo(${questionList[i].id})">
                                            ${questionList[i].questionContent}
                                    </a></h4>
                                </c:if>
                                    <%--@elvariable id="isLogin" type="java.lang"--%>
                                <c:if test="${!isLogin}">
                                    <h4>
                                        <a href="javascript:void(0);">${questionList[i].questionContent}</a>
                                    </h4>
                                </c:if>
                                <p>
                                    <c:if test="${null==questionList[i].answer.answerContent}">
                                        未回答
                                    </c:if>
                                    <c:if test="${null!=questionList[i].answer.answerContent}">
                                        ${questionList[i].answer.answerContent}
                                    </c:if>
                                </p>
                                <a href="javascript:void(0);" class="search-link">
                                        ${questionList[i].askDate}
                                </a>
                            </div>
                        </c:forEach>
                        <!-- END SEARCH RESULTS -->
                    </c:if>
                    <!-- BEGIN PAGINATION -->
                    <div class="margin-top-20">

                        <ul class="pagination">
                            <li><a href="javascript:void(0);" style="height: 31px" onclick="skipPageFirst()"><i
                                    class="fa fa-angle-double-left"></i></a></li>
                            <c:forEach var="item" varStatus="status" begin="${pageMap['beginPage']}"
                                       end="${pageMap['endPage']}">
                                <li>
                                    <c:if test="${pageMap['page']==status.index}">
                                        <span>${status.index}</span>
                                    </c:if>
                                    <c:if test="${pageMap['page']!=status.index}">
                                        <a href='javascript:void(0);'
                                           onclick='skipPage(${status.index})'> ${status.index}
                                        </a>
                                    </c:if>
                                </li>
                            </c:forEach>
                            <li><a href="javascript:void(0);" style="height: 31px" onclick="skipPageLast()"><i
                                    class="fa fa-angle-double-right"></i></a></li>
                        </ul>
                    </div>
                    <!-- END PAGINATION -->
                </div>
            </div>
        </div>
        <!-- END CONTAINER -->

    </div>
    <!-- END PAGE CONTAINER -->
    <!-- BEGIN COPYRIGHT -->
    <div class="copyright">
        <div class="container">
            <div class="row">
                <div class="col-md-8">
                    <p>
                        <span class="margin-right-10">2014 © 长春工业大学. 苏格拉没有底开发小队 版权所有 </span>
                    </p>
                </div>
                <div class="col-md-4">
                    <ul class="social-footer">
                        <li><img src="ecommerce/img/payments/western-union.jpg" alt="We accept Western Union"
                                 title="We accept Western Union"></li>
                        <li><img src="ecommerce/img/payments/american-express.jpg" alt="We accept American Express"
                                 title="We accept American Express"></li>
                        <li><img src="ecommerce/img/payments/MasterCard.jpg" alt="We accept MasterCard"
                                 title="We accept MasterCard"></li>
                        <li><img src="ecommerce/img/payments/PayPal.jpg" alt="We accept PayPal"
                                 title="We accept PayPal">
                        </li>
                        <li><img src="ecommerce/img/payments/visa.jpg" alt="We accept Visa" title="We accept Visa"></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <!-- END COPYRIGHT -->
</form>
<!-- Load javascripts at bottom, this will reduce page load time -->
<!-- BEGIN CORE PLUGINS(REQUIRED FOR ALL PAGES) -->
<!--[if lt IE 9]>
<script src="corporate/plugins/respond.min.js"></script>
<![endif]-->
<script src="corporate/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="corporate/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script src="corporate/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript" src="corporate/plugins/hover-dropdown.js"></script>
<script type="text/javascript" src="corporate/plugins/back-to-top.js"></script>
<!-- END CORE PLUGINS -->

<!-- BEGIN PAGE LEVEL JAVASCRIPTS(REQUIRED ONLY FOR CURRENT PAGE) -->
<script src="js/common/alertMsg/alertMsg.js" type="text/javascript"></script>
<script src="js/common/ccjcJS/ccjcJS.js" type="text/javascript"></script>
<script src="corporate/scripts/app.js" type="text/javascript"></script>
<script type="text/javascript">
    jQuery(document).ready(function () {
        App.init();
    });

    function skipPage(num) {
        location.href = basePath + "public/questionListDo?page=" + num;
    }
    //第一页
    function skipPageFirst() {
        $("#page").val(1);
        location.href = basePath + "public/questionListDo?page=1";
    }
    //最后一页
    function skipPageLast() {
        var page = '${pageMap.endPage}';
        location.href = basePath + "public/questionListDo?page=" + page;
    }

    function questionInfo(questionId) {
        location.href = basePath + "question/ask/questionInfoDo?questionId=" + questionId;
    }

    function myQuestion() {
        if ("" == $("#write").val().trim() || "请输入..." == $("#write").val().trim()) {
            parent.bootbox.alert("内容不能为空！");
            return;
        }
        $.ajax({
            url: basePath + "question/ask/addAskDo",
            async: false,
            data: {
                questionContent: $("#write").val().trim()
            },
            dataType: "json",
            type: "POST",
            success: function () {
                parent.bootbox.alert("提交成功！");
                location.href = basePath + "public/questionListDo";
            },
            error: function () {
                parent.bootbox.alert("提交失败！");
            }
        })
    }

    function inquiry() {
        if ("" == $("#write").val().trim() || "请输入..." == $("#write").val()) {
            parent.bootbox.alert("内容不能为空！");
            return;
        }
        $("#search").attr("action", "public/questionListDo").submit();
    }

</script>
<!-- END PAGE LEVEL JAVASCRIPTS -->

</body>
<!-- END BODY -->
</html>